#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int main()
{
	long long n,m,a[N],b[N];
	cin>>n>>m;
	long long M=m,sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i--) 
	{
		b[i]=b[i+1]+a[i];
	}
	for(int i=0;i<n;i++)
	{
		M=M-a[i];
		if(M<=0)
		{
			cout<<"NO";
			return 0;
		}
		if(a[i]==0&&M<=b[i+1])
		{
			sum=sum+m-M;
			M=m;
		}
	}
	sum=sum+n-1;
	cout<<sum<<endl;
	system("paise");
	return 0;
}
